package com.geping.etl.common.controller;


import com.geping.etl.common.dto.AddReportDto;
import com.geping.etl.common.service.Report_InfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/***
 *  报表新增接口
 * @author liang.xu
 * @date 2024.5.13
 */
@RestController
@Slf4j
public class Sys_ReportController {

    @Autowired
    private Report_InfoService report_InfoService;


    /**
     * 手工补录-添加报表
     *
     * @param addReportDto
     * @return
     */
    @RequestMapping(value = "/addSysReport", method = RequestMethod.POST)
    public Map<String, String> addSysReport(@RequestBody  AddReportDto addReportDto) {
        Map<String, String> responseJson = new HashMap<>();
        try {
            report_InfoService.addReportInfo(addReportDto);
        } catch (Exception e) {
            log.error("addSysReport error", e);
            responseJson.put("code", "000001");
            responseJson.put("msg", e.getMessage());
            return responseJson;
        }
        responseJson.put("code", "000000");
        return responseJson;
    }

    /**
     * 手工补录-编辑报表
     *
     * @param addReportDto
     * @return
     */
    @RequestMapping(value = "/editSysReport", method = RequestMethod.POST)
    public Map<String, String> editSysReport(@RequestBody  AddReportDto addReportDto) {
        Map<String, String> responseJson = new HashMap<>();
        try {
            report_InfoService.editReportInfo(addReportDto);
        } catch (Exception e) {
            log.error("addSysReport error", e);
            responseJson.put("code", "000001");
            responseJson.put("msg", e.getMessage());
            return responseJson;
        }
        responseJson.put("code", "000000");
        return responseJson;
    }

    /**
     * 手工补录-删除报表
     *
     * @param addReportDto
     * @return
     */
    @RequestMapping(value = "/delSysReport", method = RequestMethod.POST)
    public Map<String, String> delSysReport(@RequestBody  AddReportDto addReportDto) {
        Map<String, String> responseJson = new HashMap<>();
        try {
            report_InfoService.delReportInfo(addReportDto);
        } catch (Exception e) {
            log.error("delSysReport error", e);
            responseJson.put("code", "000001");
            responseJson.put("msg", e.getMessage());
            return responseJson;
        }
        responseJson.put("code", "000000");
        return responseJson;
    }
}
